#include "widget.h"
#include "ui_widget.h"
#include <QRegExp>
#include <QRegExpValidator>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    QRegExp regExp("^1\\d{10}$");
    //设置一个验证器
    ui->lineEdit->setValidator(new QRegExpValidator(regExp,this));
    ui->pushButton->setEnabled(false);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    QString s = ui->lineEdit->text();
    int pos = 0;
    if(ui->lineEdit->validator()->validate(s,pos)==2)
        ui->pushButton->setEnabled(true);
    else
        ui->pushButton->setEnabled(false);
}
